﻿using Common;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace CarPCBATest.ViewModel
{
    internal class MainViewModel : NotifyBase
    {
        private bool isOnline = true;
        private List<Task> taskList = new List<Task>();

        private string _sysTime;

        public string SysTime
        {
            get { return _sysTime; }
            set
            {
                _sysTime = value;
                this.DoNotify();
            }
        }

        public MainViewModel()
        {
            var task = Task.Factory.StartNew(new Action(async () =>
            {
                while (isOnline)
                {
                    SysTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    await Task.Delay(1000);
                }
            }));
            taskList.Add(task);
        }
    }
}